package com.yjkf.zh.test.thread;

public class MyDemo {
    public static void main(String[] args){
        MyThreadDemo myThreadDemo = new MyThreadDemo();
        new Thread(myThreadDemo,"A").start();
        new Thread(myThreadDemo,"B").start();
        new Thread(myThreadDemo,"C").start();
    }
}

class MyThreadDemo implements Runnable{

    private int ticket = 10 ;
    @Override
    public void run() {
        while (true){
            if(this.ticket>0){
                System.out.println(Thread.currentThread().getName()+"卖票"+this.ticket--);
            }else {
                System.out.println("票卖光了");
                break;
            }
        }
    }
}
